#include <iostream>
#include <string>

using namespace std;

class Building;
class GoodGay
{
public:
    GoodGay();

    void visit();//让visit函数可以访问Building中私有成员
    void visit2();//让visit2函数不可以访问Building中私有成员
    Building * building;
};

class Building
{
    friend void GoodGay::visit();
public:
    Building();
    string m_SittingRoom;
private:
    string m_BedRoom;
};

Building::Building()
{
    m_SittingRoom =  "客厅";
    m_BedRoom = "卧室";
}

GoodGay::GoodGay()
{
    building = new Building;
}

void GoodGay::visit()
{
    cout << "visit函数正在访问：" << building -> m_SittingRoom << endl;
    cout << "visit函数正在访问：" << building -> m_BedRoom << endl;
}

void GoodGay::visit2()
{
    cout << "visit2函数正在访问：" << building -> m_SittingRoom << endl;
}

void test01()
{
    GoodGay gg;
    gg.visit();
    gg.visit2();
}

int main(void)
{
    test01();

    return 0;
}